package org.example.mpdemo1.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.mpdemo1.entity.Message;

import java.util.List;

@Mapper
public interface MessageMapper extends BaseMapper<Message> {
    @Insert("insert into message values(#{sender},#{receiver},#{content},#{time})")
    int add(Message message);

    @Select("select * from message where sender=#{sender} and to=#{receiver}")
    Message findBySenderAndTo(int sender, int receiver);

    @Select("select * from message")
    List<Message> getAll();

    @Delete("delete from message")
    int deleteAll();
}
